
#ifndef _TTG_SERVICES_TASKSCHEDULER_ITASKSCHEDULER_
#define _TTG_SERVICES_TASKSCHEDULER_ITASKSCHEDULER_
#include "Common/Definitions.h"

#include "Common/Structures.h"
#include "Runtime.Low/Threads.h"

namespace ttg
{
	namespace services
	{
		//Interface, that receives ready task and gives them to task scheduler.
		template <class TaskType>
		class ITaskScheduler
		{
			public:
				//Adds set of tasks.
				virtual void addTasks(ttg::structures::Enumerator<TaskType> &en) = 0;
				//Splits "tasks" into root and child tasks.
				//Child tasks will be performed by the same performer.
				//Root tasks will be sent to task scheduler.
				virtual void split(std::vector<TaskType> &tasks,
								   std::vector<TaskType> &root_tasks,
								   std::vector<TaskType> &child_tasks) = 0;
				//Adds one task.
				inline void addTask(TaskType task)
				{ addTasks(ttg::structures::ValueEnumerator<TaskType>(task)); }
				//Adds set of tasks, that are contained in a vector.
				inline void addTasks(std::vector<TaskType> &tasks)
				{ addTasks(ttg::structures::StlEnumerator
										<TaskType, std::vector<TaskType>::iterator>
										(tasks.begin(), tasks.end())); }
				//Adds set of tasks, that are contained in a list.
				inline void addTasks(std::list<TaskType> &tasks)
				{ addTasks(ttg::structures::StlEnumerator
										<TaskType, std::list<TaskType>::iterator>
										(tasks.begin(), tasks.end())); }
		};
	}
}

#endif
